"""
尝试失败，因为百度的图片加载是在js里进行的，无法直接通过brautifulsoup来爬
"""


from bs4 import BeautifulSoup
import requests

url = "http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=python"

headers = {"user-agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0"}
html = requests.get(url,headers = headers).text
soup = BeautifulSoup(html,"lxml")


#img_divs = soup.find("div",{"id":"wrapper"})
img_divs = soup.find("div",{"class":"memory-con"})
print(img_divs)
i=0
for img_div in img_divs:
    print(img_div)
    i+=1
print(i)
'''
.find("div",{"class":"imgpage"}).find("ul",{"class":"imglist clearfix pageNum0"}).find_all("data-objurl")


for img_div1 in img_divs:
    img_div2 = img_div1.find_all("div",{"class":"imgpage"})
    print(len(img_div2))
    for img_div3 in img_div2:
        img_div4 = img_div3.find_all("ul",{"class":"imglist clearfix pageNum0"})
'''